import numpy as np
import pandas as pd
from pandas import Series, DataFrame

df = pd.read_csv( "E:\\testpython\\test.csv" )
# print( df )
'''
    Price  Segno Symbol
0  1623.0    0.0   appl
1  1624.0    1.0   appl
2  1625.0    0.0   appl
3  1626.0    1.0   appl
4  1627.0    0.0   appl
'''
df1 =  df["Segno"].unique()
# print( df1, len( df1 ) )
'''
[ 0.  1.] 2
索引是0和1，表示索引是0和1的值是唯一的
'''
df2 = df["Segno"].duplicated()
# print( df2 )
''' 查看该列的重复情况
0    False
1    False
2     True
3     True
4     True
Name: Segno, dtype: bool
'''
df3 = df["Segno"].drop_duplicates()
# print( df3 )
''' 仅仅将该列的唯一值返回
0    0.0
1    1.0
Name: Segno, dtype: float64
'''
df4 = df.drop_duplicates( ["Segno"] )
# print( df4 )
''' 按照segno这一列的去重，对整个DataFrame进行整理，默认保存重复值的第一条数据
    Price  Segno Symbol
0  1623.0    0.0   appl
1  1624.0    1.0   appl
'''
# drop_duplicates() 第二个参数keep，用来设置保存哪一个重复值
df5 = df.drop_duplicates( ["Segno"], keep = "last" )
print( df5 )
''' keep参数中的last，表示查找到重复值之后，保存最后一个重复值的内容，默认是first
    Price  Segno Symbol
3  1626.0    1.0   appl
4  1627.0    0.0   appl
'''